﻿Imports System.Data.SqlClient

Public Class clsE_Roles
    Private mintIdRol As Integer
    Private mstrNombre As String
    Private mstrSalida As String
    Private mstrLlegada As String
    Private mstrTipoDia As String
    Private mintEncontrado As Integer
    Public Property IdRol() As Integer
        Get
            Return mintIdRol
        End Get
        Set(ByVal value As Integer)
            mintIdRol = value
        End Set
    End Property
   

    Public Property Nombre() As String
        Get
            Return mstrNombre
        End Get
        Set(ByVal value As String)
            mstrNombre = value
        End Set
    End Property

    Public Property Salida() As String
        Get
            Return mstrSalida
        End Get
        Set(ByVal value As String)
            mstrSalida = value
        End Set
    End Property

    Public Property Llegada() As String
        Get
            Return mstrLlegada
        End Get
        Set(ByVal value As String)
            mstrLlegada = value
        End Set
    End Property

    Public Property TipoDia() As String
        Get
            Return mstrTipoDia
        End Get
        Set(ByVal value As String)
            mstrTipoDia = value
        End Set
    End Property
    Public Property Encontrado() As Integer
        Get
            Return mintEncontrado
        End Get
        Set(ByVal value As Integer)
            mintEncontrado = value
        End Set
    End Property
   
    Public Sub New()
        mintIdRol = 0
        mstrNombre = ""
        mstrSalida = ""
        mstrLlegada = ""
        mstrTipoDia = ""
        mintEncontrado = 0
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into E_Roles (" & _
                            "Nombre," & _
                            "Salida," & _
                            "Llegada," & _
                            "TipoDia, " & _
                            "Encontrado)" & _
                            "VALUES (" & _
                            "@Nombre," & _
                            "@Salida," & _
                            "@Llegada," & _
                            "@TipoDia, " & _
                            "@Encontrado)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("Nombre", mstrNombre)
        Command.Parameters.AddWithValue("Salida", mstrSalida)
        Command.Parameters.AddWithValue("Llegada", mstrLlegada)
        Command.Parameters.AddWithValue("TipoDia", mstrTipoDia)
        Command.Parameters.AddWithValue("Encontrado", mintEncontrado)

        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
        Catch ex As Exception
            'MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Aviso")
        End Try

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            'MsgBox("No fue posible insertar rol", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
